package com.thxrinfo.stop.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.thxrinfo.stop.api.entity.Region;
import com.thxrinfo.stop.mapper.RegionMapper;
import com.thxrinfo.stop.service.RegionService;
import org.springframework.stereotype.Service;

/**
 * 停车场区域
 *
 * @author ct
 * @date 2023-02-02 13:41:56
 */
@Service
public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> implements RegionService {
	@Override
	public IPage<Region> page(Page page, Region region) {
		LambdaQueryWrapper<Region> queryWrapper = new LambdaQueryWrapper<>();
		if (region.getParkId() != null) {
			queryWrapper.eq(Region::getParkId, region.getParkId());
		}
		if (region.getRegionName() != null) {
			queryWrapper.like(Region::getRegionName, region.getRegionName());
		}
		if (region.getIsOnlyMonthly() != null) {
			queryWrapper.eq(Region::getIsOnlyMonthly, region.getIsOnlyMonthly());
		}
		queryWrapper.last(" order by ".concat("update_time desc"));
		return this.page(page, queryWrapper);
	}
}
